#!/bin/sh
# script to wrap xterm 

if [ -z "$GRASS_XTERM" ] ; then
   # find a working xterm or xterm compatible executable
   TERM_TRY="xterm rxvt x-terminal-emulator"
   for TERM_PROG in $TERM_TRY ; do
      if [ -x "`which $TERM_PROG`" ] ; then
         GRASS_XTERM="$TERM_PROG"
         break
      fi
   done
   if [ -z "$GRASS_XTERM" ] ; then
      # no luck, use a default
      g.message -w "No terminal program found, trying xterm"
      GRASS_XTERM=xterm
   fi
fi

# run command
exec "$GRASS_XTERM" "$@"
